import React from 'react';
import ToastView from './ToastView'
import ToastRootView from "./ToastRootView";

class Toast {
    public static LONG = 2000;
    public static SHORT = 1000;

    public static show(msg:string, time?:number) {
        if(!time){
            ToastRootView.setView(<ToastView
                message={msg}
                onDismiss={() => {
                    ToastRootView.setView(null)
                }}/>)
        }
        else {
            ToastRootView.setView(<ToastView
                message={msg}
                time={time}
                onDismiss={() => {
                    ToastRootView.setView(null)
                }}/>)
        }
    }
}

export default Toast
